{% set pypi_name = 'oslo.utils' %}
{% set upstream_version = upstream_version('4.7.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Utils Library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Babel') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('iso8601') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('monotonic') }}
BuildRequires:  {{ py3('netaddr') }}
BuildRequires:  {{ py3('netifaces') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pyparsing') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
The oslo.utils library provides support for common utility type functions,
such as encoding, exception handling, string manipulation, and time handling.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Utils Library
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('iso8601') }}
Requires:       {{ py3('netaddr') }}
Requires:       {{ py3('netifaces') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('pyparsing') }}
Requires:       {{ py3('pytz') }}
Requires:       {{ py3('six') }}

%description -n {{ py2name(py_versions='py3') }}
The oslo.utils library provides support for common utility type functions,
such as encoding, exception handling, string manipulation, and time handling.

This package contains the Python 3.x module.

%package -n {{ py2name() }}-doc
Summary:        Documentation for OpenStack utils library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name() }}-doc
Documentation for OpenStack utils library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}

%py_req_cleanup

%build
%py3_build

%install
%py3_install

# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%check
# tests fail with python 3.8
rm -v oslo_utils/tests/test_reflection.py
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/oslo_utils
%{python3_sitelib}/*.egg-info

%files -n {{ py2name() }}-doc
%doc doc/build/html
%license LICENSE

%changelog
